<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

        <title>用户管理</title>

        <link href="../../css/mine.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="/jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            /*全选方法*/
            $(function(){

                $("#buttonAll").click(function(){
                    /*得到点击按钮的状态*/
                    /*jq->js*/
                    var status=$(this)[0].checked;
                    //设置全选
                    var cks=document.getElementsByName("empId");

                    for (var i = 0; i < cks.length; i++) {
                        console.log(cks[i])
                        cks[i].checked=status;
                    }
                })
            });

            //批量删除
            function deleteAll(){
                var name = document.getElementsByName("empId");
                if (name[0].checked==true) {
                    document.getElementById("myMethod").value="deleteAll";
                    document.forms[1].submit();
                } else {
                    alert("请选择要导出的数据");
                }

            }

            //导出数据
            function checkOut(){
                var name = document.getElementsByName("empId");
                if (name[0].checked==true) {
                    document.getElementById("myMethod").value = "doExcle";
                    document.forms[1].submit();
                } else {
                    alert("请选择要导出的数据");
                }
            }

        </script>
        <style type="text/css">
            .tr_color{background-color: #9F88FF}
            #deleteAll{
                color: green;
                cursor: pointer;
            }
            #excle{
                color: green;
                cursor: pointer;
            }
        </style>
    </head>
    <body>

        <div class="div_head">
            <span>
                <span style="float: left;">当前位置是：系统管理-》用户管理</span>
                <span style="float: right; margin-right: 8px; font-weight: bold;">
                    <span id="excle" style="text-decoration: none;"  onclick="checkOut()">【导出数据】</span>
                    <a style="text-decoration: none;" href="/resource/demo2/addEmpPre">【添加】</a>
					<span id="deleteAll"  onclick="deleteAll()">【删除】</span>
                </span>
            </span>
        </div>
        <div></div>
        <div class="div_search">
            <span>
                <form action="/resource/demo2/list" method="get">
                     姓名：
					<input type="text"  name="userName" value="${userName}"/>
					 角色: 
					<input type="text"  name="roleName" value="${roleName}"/>
					 所属部门: 
					<input type="text"  name="deptName" value="${deptName}"/>
                    <input value="查询" type="submit" />
					
                </form>
            </span>
        </div>
        <div style="font-size: 13px; margin: 10px 5px;">
            <table class="table_a" border="1" width="100%">
                <tbody>
						<tr style="font-weight: bold;">						
                        <td width="40px;">序号</td>
                        <td width="30px;"><input type="checkbox"   id="buttonAll"/></td>
						<td width="80px;">账号</td>
                        <td width="80px;">姓名</td>
                        <td >角色</td>
						<td width="100px;">所属部门</td>                                        
                        <td align="center" width="100px;">操作</td>
                    </tr>
                        <%--批量删除--%>
                        <form action="/resource/demo2/doAction" method="post" id="sub">
                            <input type="hidden" id="myMethod" name="method">
                            <c:forEach items="${pageInfo.list}" var="emp" varStatus="sta">
                                <tr id="product1">
                                    <td>${sta.count}</td>
                                    <c:if test="${emp.id==user.id}">
                                    <td><input type="hidden"   /></td>
                                    </c:if>
                                    <c:if test="${emp.id!=user.id}">
                                    <td><input type="checkbox"  name="empId"  value="${emp.id}"/></td>
                                    </c:if>
                                    <td>${emp.loginNumber}</td>
                                    <td><a href="/resource/demo2/view?empId=${emp.id}">${emp.userName}</a></td>
                                    <td>${emp.userRole.roleName}</td>
                                    <td>${emp.department.deptName}</td>
                                    <td>
                                        <a href="/resource/demo2/preUpdate?empId=${emp.id}">修改</a>
                                        <c:if test="${emp.id!=user.id}">
                                            <a href="/resource/demo2/deleteEmp?empId=${emp.id}">删除</a>
                                        </c:if>
                                    </td>
                                </tr>
                            </c:forEach>
                        </form>

                    <tr>
                        <td colspan="20" style="text-align: center;">
                            <a style="text-decoration: none;" href="/resource/demo2/list?&userName=${userName}&roleName=${roleName}&deptName=${deptName}">首页</a>
                            <a style="text-decoration: none;" href="/resource/demo2/list?page=${pageInfo.prePage==0?1:pageInfo.prePage}&userName=${userName}&roleName=${roleName}&deptName=${deptName}"> 上一页  </a>
                            <a style="text-decoration: none;" href="/resource/demo2/list?page=${pageInfo.nextPage==0?pageInfo.pages:pageInfo.nextPage}&userName=${userName}&roleName=${roleName}&deptName=${deptName}">下一页  </a>
                            <a style="text-decoration: none;" href="/resource/demo2/list?page=${pageInfo.pages}&userName=${userName}&roleName=${roleName}&deptName=${deptName}"> 尾页 </a>
                            共${pageInfo.pages}页 每页显示 ${pageInfo.pageSize}/${pageInfo.total}
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
</html>